<template>
	<el-dialog title="归档对话框" v-model="visible" :width="500" destroy-on-close @closed="$emit('closed')">
		<el-form :model="form" :rules="rules" ref="dialogForm" label-width="100px" label-position="left">
			<el-form-item label="公文名称">
				{{flowName}}
			</el-form-item>
			<el-form-item label="选择年度">
				<el-select v-model="form.sealedYear" style="width: 100%">
					<el-option v-for="item in yearList" :key="item.sealedYear" :label="item.sealedYear" :value="item.sealedYear"></el-option>
				</el-select>
			</el-form-item>
		</el-form>
		<template #footer>
			<el-button @click="visible=false">取 消</el-button>
			<el-button v-if="mode!='show'" type="primary" :loading="isSaveing" @click="submit()">归 档</el-button>
		</template>
	</el-dialog>
</template>

<script>
export default {
	components: {},
	emits: ['success', 'closed'],
	data() {
		return {
			visible: false,
			isSaveing: false,
			yearList:[],
			flowName: "",
			//表单数据
			form: {
				flowId: "",
				sealedYear:'',
			},
			//验证规则
			rules: {}
		}
	},
	mounted() {
		this.getBpmListYear();
	},
	methods: {
		//显示
		open() {
			this.visible = true;
			return this
		},
		//表单提交方法
		async submit() {
			var res = await this.$API.bpm.bpmSealed.doSealedBpmByFlowId.post(this.form);
			if(res.code==200)
			{
				this.visible = false;
				this.$message.success("操作成功")
			}else
			{
				this.$alert(res.message, "提示", {type: 'error'})
			}
		},
		async getBpmListYear(){
			var res = await this.$API.bpm.bpmSealed.getBpmListYear.get({flowId:this.form.flowId});
			if(res.code==200)
			{
				this.yearList = res.data;
			}
		},
		setData(data) {
			this.form.flowId = data.flowId;
			this.flowName = data.flowName;
		}
	}
}
</script>

<style>
</style>
